import org.grails.plugins.springsecurity.service.AuthenticateService

class ProfileController {

	AuthenticateService authenticateService
	def daoAuthenticationProvider

	def allowedMethods = [save: 'POST', update: 'POST']

	/**
	 * User Registration Top page
	 */
	def index = {

		if (authenticateService.userDomain() && session.id) {
            log.info("show profile")
            render(view: 'show', model: [person: User.get(params.id)])           
		}
        else {
            redirect(controller: 'login')
        }
	}

	/**
	 * User Information page for current user.
	 */
	def show = {

		//get user id from session's domain class.
		def user = authenticateService.userDomain()
		if (user) {
			render(view: 'show', model: [person: User.get(user.id)])
		}
		else {
			redirect(action: 'index')
		}
	}
}
